﻿<?php
session_start();
include('functions.php');
connect();
// See if the user has access to do this
$id=$_SESSION["id"];
$q=mysql_query("select roledescription from person where id=$id");
$roledescription=mysql_fetch_row($q);
$roledescription=$roledescription[0];
$q=mysql_query("select description from permission where roledescription='$roledescription'");
$hasaccess=false;
for ($i=0; $i<mysql_num_rows($q); $i++){
	$description=mysql_fetch_row($q);
	if ($description="chooselesson")
		$hasaccess=true;
}
// Do the thing
if ($hasaccess){
	$q=mysql_query("select * from lesson");
	for ($i=0; $i<mysql_num_rows($q); $i++){
		$s=mysql_fetch_row($q);
		echo "$s[0] $s[2] <a href=\"chooselesson1.php?lessonid=$s[1]\">انتخاب</a><br />";
	}
}
else{
	echo "شما اجازه ی دسترسی به این قسمت را ندارید";
}
?>
